/*
 * Copyright (c) 2025 EasyAdmin
 * All rights reserved.
 *
 * This file is part of the [EasAdmin] project.
 * Unauthorized copying of this file, via any medium, is strictly prohibited.
 * Proprietary and confidential.
 *
 * Author: EasyAdmin ( 1073602@qq.com )
 * Website: https://www.xhxiao.com
 */
package com.easy.module.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.easy.framework.common.validate.Add;
import com.easy.framework.common.validate.Update;
import com.easy.framework.database.entity.LogicDeleteEntity;
import com.easy.framework.poi.annotation.Excel;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * 菜单权限表 实体
 *
 * @author EasyAdmin ( 1073602@qq.com )
 * @date 2025-08-19
 */
@Getter
@Setter
@TableName("sys_menu")
public class SysMenu extends LogicDeleteEntity
{
    private static final long serialVersionUID = 1L;

    /**
     * 菜单ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;


    /**
     * 父级菜单ID
     *
     */
    @NotNull(message="父级菜单ID不能为空", groups = {Add.class,Update.class})
    private Long parentId;


    /**
     * 菜单名称
     *
     */
    @NotBlank(message="菜单名称不能为空", groups = {Add.class,Update.class})
    @Size(message = "菜单名称长度必须小于20个字符", max = 20, groups = {Add.class, Update.class})
    private String name;


    /**
     * 类型（B板块 M目录 C菜单 F按钮）
     *
     */
    @NotBlank(message="类型不能为空", groups = {Add.class,Update.class})
    private String type;


    /**
     * 顺序
     *
     */
    @NotNull(message="顺序不能为空", groups = {Add.class,Update.class})
    private Integer sort;


    /**
     * 路由地址
     *
     */
    @Size(message = "路由地址长度必须小于100个字符", max = 100, groups = {Add.class, Update.class})
    private String path;


    /**
     * 组件路径
     *
     */
    @Size(message = "组件路径长度必须小于100个字符", max = 100, groups = {Add.class, Update.class})
    private String component;


    /**
     * 路由参数
     *
     */
    @Size(message = "路由参数长度必须小于255个字符", max = 255, groups = {Add.class, Update.class})
    private String query;


    /**
     * 是否外链（0否 1是）
     *
     */
    private Boolean isFrame;


    /**
     * 是否缓存（0不缓存 1缓存）
     *
     */
    private Boolean isCache;


    /**
     * 是否可见（0隐藏 1显示）
     *
     */
    private Boolean visible;


    /**
     * 是否跳转路由（0否 1是）
     * 为是时需要完整的路由地址
     * 如：/user/role
     */
    private Boolean redirect;

    /**
     * 激活菜单完整路由
     */
    @Size(message = "激活菜单完整路由长度必须小于255个字符", max = 255, groups = {Add.class, Update.class})
    private String activePath;


    /**
     * 状态（0正常 1停用）
     *
     */
    @NotNull(message="状态不能为空", groups = {Add.class,Update.class})
    private Integer status;


    /**
     * 权限标识
     *
     */
    @Size(message = "权限标识长度必须小于32个字符", max = 32, groups = {Add.class, Update.class})
    private String sign;


    /**
     * 图标
     *
     */
    @Size(message = "图标长度必须小于64个字符", max = 64, groups = {Add.class, Update.class})
    private String icon;

    /**
     * 页面编号
     *
     */
    private Integer pageId;

    /**
     * 子菜单
     */
    @TableField(exist = false)
    private List<SysMenu> children = new ArrayList<>();

    /**
     * 是否有子菜单
     */
    @TableField(exist = false)
    private boolean hasChildren = false;
}
